import Vue from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'
import BaiduMap from 'vue-baidu-map'
import { Toast, PullRefresh } from 'vant';
import appConfig from './config'
import http from './api'
import './registerServiceWorker'
import 'vant/lib/index.css';

Vue.use(BaiduMap, {
  ak: appConfig.baiduMapAK
})
Vue.config.productionTip = false
Vue.component('PullRefresh', PullRefresh);

Vue.prototype.$http = http;
Vue.prototype.$showLoading = () => {
  Toast.loading({
    message: '加载中...',
    duration: 0,
    forbidClick: true
  })
}
Vue.prototype.$hideLoading = () => {
  Toast.clear();
}

new Vue({
  router,
  store,
  render: h => h(App)
}).$mount('#app')

if (process.env.NODE_ENV !== 'production' && /micromessenger/.test(navigator.userAgent.toLowerCase())) {
  const hm = document.createElement('script');
  hm.src = '//cdn.jsdelivr.net/npm/vconsole@3.2.2/dist/vconsole.min.js';
  hm.onload = () => {
    new window.VConsole();
  };
  const s = document.getElementsByTagName('body')[0];
  s.parentNode.insertBefore(hm, s);
}
